Skip to content

fix(files_sharing): normalize share target on parent folder rename - #63956

Open
silverkszlo wants to merge 2 commits into
masterfrom
fix/trailing-slash-file-share
Open

fix(files_sharing): normalize share target on parent folder rename#63956
silverkszlo wants to merge 2 commits into
masterfrom
fix/trailing-slash-file-share

Conversation

@silverkszlo

Copy link
Copy Markdown

Summary

When a recipient moved an incoming share into one of their own folders and later renamed that folder, Updater::renameChildren passed the mount point to SharedMount::moveMount. Mount points always end in a slash, and stripUserFilesPath did not normalize its result, so the slash was stored in share.file_target. PROPFIND on such a share then returns 500.

Normalize the stripped path so no caller can write a trailing slash, and repair rows that are already affected.

To reproduce

  • As owner: create test.odt (or a folder) in Files and share it with recipient
  • As recipient: create your own folder at home root, e.g. box
  • As recipient: move the received test.odt into box
  • As recipient: rename box, e.g. "box_renamed"
  • Then check occ share:list --recipient=[recipient]
    → The name of the share has a trailing slash in target-path: /box_renamed/test.odt/

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

When a recipient moved an incoming share into one of their own folders
and later renamed that folder, Updater::renameChildren passed the mount
point to SharedMount::moveMount. Mount points always end in a slash, and
stripUserFilesPath did not normalize its result, so the slash was stored
in share.file_target. PROPFIND on such a share then returns 500.

Normalize the stripped path so no caller can write a trailing slash, and
repair rows that are already affected.

Signed-off-by: silver <s.szmajduch@posteo.de>
Assisted-by: ClaudeCode:claude-opus-5
@silverkszlo silverkszlo added the bug label Sep 2, 2026
@silverkszlo
silverkszlo requested a review from a team as a code owner September 2, 2026 13:02
@silverkszlo silverkszlo added the 3. to review Waiting for reviews label Sep 2, 2026
@silverkszlo
silverkszlo requested review from Altahrim, icewind1991, leftybournes and sorbaugh and removed request for a team September 2, 2026 13:02
@silverkszlo
silverkszlo requested a review from blizzz September 2, 2026 13:03
$query = $this->connection->getQueryBuilder();
$query->select('id', 'file_target')
->from('share')
->where($query->expr()->like('file_target', $query->createNamedParameter('%/')))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not use any index thus is extremely expensive on big instances.
Meaning we likely want to only run this once for one update and later do it not again on the next update.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe since this is needed to fix an issue and we need to backport it down to the first version with authoritative mount points, it probably makes sense to instead make a new repair step and register it as expensive, so users get the hint that they should run it when they can, rather than cramping it during the update. WDYT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think two options:

  1. Make it its own repair step (expensive repair step) -> allow manually re-triggering
  2. Keep in this repair step but add appconfig flag "has this been done already" and if yes do not run again

Comment thread lib/private/Repair/RepairInvalidShares.php
@salmart-dev

Copy link
Copy Markdown
Contributor

Tested on master, fixes the issue so besides the expensive repair step running at every upgrade, it looks good to me.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants